<template>
  <div class="singerlist">
    <div class="singer-box">
      <!-- 语种 -->
      <div class="classification">
        <ul>
          <li><span>语种:</span></li>
          <li
            :style="{ color: item.name == languagesName ? themecolor : '' }"
            v-for="(item, index) in languages"
            :key="index"
            @click="onlanguages(item.area, item.name)"
          >
            <span>{{ item.name }}</span>
          </li>
        </ul>
      </div>
      <!-- 分类 -->
      <div class="classification">
        <ul>
          <li><span>分类:</span></li>
          <li
            :style="{ color: item.name == typeName ? themecolor : '' }"
            v-for="(item, index) in species"
            :key="index"
            @click="onspecies(item.type, item.name)"
          >
            <span>{{ item.name }}</span>
          </li>
        </ul>
      </div>
      <!-- 筛选 -->
      <div class="screening">
        <ul>
          <li><span>筛选:</span></li>
          <li
            :style="{ color: item == letter ? themecolor : '' }"
            v-for="(item, index) in screening"
            :key="index"
            @click="onscreening(item)"
          >
            <span>{{ item }}</span>
          </li>
        </ul>
      </div>
    </div>
    <!-- 歌手列表 -->
    <!-- <artist-list /> -->
    <div class="artist-list">
      <div
        class="artist-item"
        v-for="item in artists"
        :key="item.id"
        @click="tosingerdetails(item.id)"
      >
        <div class="image">
          <img :src="item.img1v1Url" :alt="item.name" :title="item.name" />
        </div>
        <p>{{ item.name }}</p>
      </div>
    </div>
    <!-- 分页 -->
    <el-pagination
      background
      layout="prev, pager, next, jumper"
      :current-page="page"
      :page-count="page"
      :total="500"
      @current-change="currentchange"
    >
    </el-pagination>
  </div>
</template>

<script>
// import ArtistList from './components/artistlist'
import { getArtist } from "@/api/singer.js";
export default {
  name: "SingerList",
  components: {
    // ArtistList
  },
  props: {},
  data() {
    return {
      themecolor: localStorage.getItem("themeColor"), // 颜色
      languages: [
        { name: "全部", area: -1 },
        { name: "华宇", area: 7 },
        { name: "欧美", area: 96 },
        { name: "日本", area: 8 },
        { name: "韩国", area: 16 },
        { name: "其他", area: 0 }
      ],
      area: -1,
      languagesName: "全部",
      species: [
        { name: "全部", type: -1 },
        { name: "男歌手", type: 1 },
        { name: "女歌手", type: 2 },
        { name: "乐队", type: 3 }
      ],
      type: -1,
      typeName: "全部",
      screening: [
        "热门",
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "K",
        "L",
        "M",
        "N",
        "O",
        "P",
        "Q",
        "R",
        "S",
        "T",
        "U",
        "V",
        "W",
        "X",
        "Y",
        "Z",
        "#"
      ],
      initial: -1,
      letter: "热门",
      artists: "",
      limit: 30,
      page: 1,
      total: 0
    };
  },
  computed: {
    themeColor() {
      return this.$store.state.themeColor;
    }
  },
  watch: {
    themeColor() {
      this.themecolor = this.$store.state.themeColor;
    }
  },
  created() {
    this.getArtist();
  },
  mounted() {},
  methods: {
    onlanguages(area, name) {
      this.area = area;
      this.languagesName = name;
      this.page = 1;
      this.title();
      this.getArtist();
    },
    onspecies(type, name) {
      this.type = type;
      this.page = 1;
      this.typeName = name;
      this.title();
      this.getArtist();
    },
    onscreening(initial) {
      this.letter = initial;
      if (initial == "热门") {
        this.initial = -1;
      } else if (initial == "#") {
        this.initial = 0;
      } else {
        this.initial = initial;
      }
      this.page = 1;
      this.getArtist();
    }, //获取歌手
    async getArtist() {
      this.showLoading();
      const data = await getArtist({
        limit: this.limit,
        type: this.type,
        area: this.area,
        initial: this.initial,
        offset: (this.page - 1) * this.limit
      });
      if (data.status == 200) {
        this.closeLoading();
        this.artists = data.data.artists;
      }
    },
    currentchange(page) {
      this.page = page;
      this.getArtist();
      document.querySelector(".el-main").scrollTop = 0;
    },
    tosingerdetails(id) {
      this.$router.push({
        path: "/singerdetails",
        query: {
          id
        }
      });
    },
    title() {
      document.title = `${this.languagesName}${
        this.typeName == "全部" ? "歌手" : this.typeName
      } - 音乐盒`;
    }
  }
};
</script>

<style scoped lang="scss">
.singerlist {
  margin-bottom: 6.25rem;
  padding: 0 9.375rem;
  .singer-box {
    .classification {
      ul {
        li {
          list-style: none;
          display: inline-block;
          width: 5rem;
          height: 1.875rem;
          text-align: center;
          line-height: 1.875rem;
          cursor: pointer;
        }
        .area-active {
          color: var(--light-text-tint);
        }
        .area-active1 {
          color: var(--dark-active-color);
        }
        .area-active2 {
          color: var(--green-active-color);
        }
      }
    }
    .screening {
      ul {
        li {
          list-style: none;
          display: inline-block;
          width: 2.1875rem;
          height: 1.875rem;
          text-align: center;
          line-height: 1.875rem;
          cursor: pointer;
        }
        li:nth-child(1) {
          width: 5rem;
          height: 1.875rem;
          text-align: center;
          line-height: 1.875rem;
        }
        li:nth-child(2) {
          width: 5rem;
          height: 1.875rem;
          text-align: center;
          line-height: 1.875rem;
        }
        .area-active {
          color: var(--light-text-tint);
        }
        .area-active1 {
          color: var(--dark-active-color);
        }
        .area-active2 {
          color: var(--green-active-color);
        }
      }
    }
  }
  .artist-list {
    display: flex;
    flex-wrap: wrap;
    margin-top: 3.125rem;
    .artist-item {
      width: 16.66667%;
      padding: 0.35714rem 0.71429rem;
      cursor: pointer;
      box-sizing: border-box;
      .image {
        position: relative;
        width: 100%;
        border-radius: 0.625rem;
        height: 11.25rem;

        overflow: hidden;
        // border: 1px solid #ccc;
        // height: 100%;
        // width: 100%;
        img {
          position: absolute;
          display: block;
          width: 100%;
          // height: 100%;
          border-radius: 0.625rem;
          transition: all 0.5s;
        }
      }
      p {
        text-align: center;
      }
    }
  }
  img:hover {
    transform: scale(1.2);
    // box-shadow: 0px 5px 10px #888888;
  }
}
</style>
